{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "CIS-522 Week 1 Homework",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hwKKo5_FzsXP"
      },
      "source": [
        "# CIS-522 Week 1 Homework\n",
        "\n",
        "\n",
        "**Instructor:** Konrad Kording\n",
        "\n",
        "**Content Creators:** Ari Benjamin, Jordan Lei"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "8kdBhPZj3mPh"
      },
      "source": [
        "#@markdown What is your Pennkey and pod? (text, not numbers, e.g. bfranklin)\n",
        "my_pennkey = 'value' #@param {type:\"string\"}\n",
        "my_pod = 'euclidean-wombat' #@param ['Select', 'euclidean-wombat', 'sublime-newt', 'buoyant-unicorn', 'lackadaisical-manatee','indelible-stingray','superfluous-lyrebird','discreet-reindeer','quizzical-goldfish','ubiquitous-cheetah','nonchalant-crocodile','fashionable-lemur','spiffy-eagle','electric-emu','quotidian-lion','astute-jellyfish', 'quantum-herring']\n",
        "\n",
        "# start timing\n",
        "import time\n",
        "try:t0;\n",
        "except NameError: t0 = time.time()\n"
      ],
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "N7s6B1jx0djA"
      },
      "source": [
        "## Part 1. Deep Learning: Changing the Game\n",
        "We just saw how a simplified version of Alphazero could effectively learn how to play Othello. In the past few years, Deep Learning agents have outperformed humans in games ranging from Atari to Go. In this module, we take a look into some of the societal implications of this technology. \n",
        "\n",
        "Wait, wait! Before you roll your eyes, let’s be clear - the goal of this module is not to convince you that Deep Learning is the best thing since sliced bread, nor is it meant to stoke fears about the robot overlords taking over. Instead, our goal in this module, and the goal of this course, is to take a nuanced view into how we can build algorithms that can improve the world around us, while also recognizing the shortcomings and pitfalls of these artificial agents. \n",
        "\n",
        "Let’s start out by taking a look at how strategic agents like AlphaGo and AlphaZero have transformed game-playing communities. I’m guessing you have a few thoughts about this already. Why don’t you jot them down? "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "WLV3TQOdzWBM"
      },
      "source": [
        "#@title What are your General Thoughts? { display-mode: \"form\" }\n",
        "\n",
        "general_thoughts = 'value' #@param {type:\"string\"}\n",
        "try:t1;\n",
        "except NameError: t1 = time.time()"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oDjCjSsS02dD"
      },
      "source": [
        "### Ready, Set, Go\n",
        "Great! Now, read the following article to familiarize yourself with the famous match between Lee Sedol and AlphaGo. Play close attention to the descriptions of Move 37 and Move 78. \n",
        "\n",
        "https://www.wired.com/2016/03/two-moves-alphago-lee-sedol-redefined-future/\n",
        "\n",
        "And now read the following article on how the Sedol-AlphaGo match has influenced the Go gameplay community:\n",
        "\n",
        "https://www.newyorker.com/tech/annals-of-technology/in-the-age-of-google-deepmind-do-the-young-go-prodigies-of-asia-have-a-future\n",
        "\n",
        "**Now, give a brief reflection [200-300 words] on the following questions:** \n",
        "* Was there anything in the New Yorker article that surprised you, or was the outcome exactly as expected?\n",
        "* Given that algorithms like AlphaGo and AlphaZero can easily outperform humans, what is the role of masters in this game? Should we redefine what it means to play well, and if so, how?\n",
        "* The New Yorker article mentioned the potential for algorithms to teach new students. Can you think of some ways this will impact younger students in the gameplaying industry? Try to think of both benefits and drawbacks of this new technology. \n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "NKzn8-f31OgY"
      },
      "source": [
        "#@title Your Response Here\n",
        "\n",
        "reflection_1 = 'value' #@param {type:\"string\"}\n",
        "try:t2;\n",
        "except NameError: t2 = time.time()"
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qPX9amdE1iao"
      },
      "source": [
        "### The Perfect Match?\n",
        "That was kind of a bummer, huh? Based on what we’ve seen so far, it would be easy to feel like Deep Learning can only harm the game-playing community, by turning games that were once interesting obsolete. Not so fast! Is it possible that Deep Learning might actually help, rather than hurt gameplay? Let’s take a look at the following articles: \n",
        "\n",
        "https://www.wired.com/story/ai-ruined-chess-now-making-game-beautiful/\n",
        "\n",
        "https://time.com/5779217/artificial-intelligence-video-games/\n",
        "\n",
        "**Now, give a brief reflection [200-300 words] on the following questions:** \n",
        "*   Was there anything in these articles that surprised you? Or was this all expected? \n",
        "*   If you were a data scientist leveraging Deep Learning to design new video games, what kind of ethical considerations would you leave to the agents, and which would you explicitly prescribe? How can this creativity be harnessed for good? \n",
        "*   An increasingly relevant concern is the possibility of artificial agents taking human jobs. In the context of game-play communities, how might we think about redesigning or redefining the role of humans in the industry? What kinds of training or expertise will these new roles require, and what might be an effective way to manage this transition?\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "exOEGXMD1hwQ"
      },
      "source": [
        "#@title Your Response Here\n",
        "\n",
        "reflection_2 = 'value' #@param {type:\"string\"}\n",
        "try:t3;\n",
        "except NameError: t3 = time.time()"
      ],
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kPyknvoP2y6T"
      },
      "source": [
        "### Submission\n",
        "Double check that the answers have been correctly formatted in the Airtable below, and edit them as desired. **In addition to submitting the form, contribute and reflect on these readings in the student Slack space.**"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 422
        },
        "id": "anCjE03r3cJ6",
        "outputId": "52742a38-094f-4fbb-ed6d-f0b9a8e31501"
      },
      "source": [
        "#@markdown #Run Cell to Show Airtable Form\n",
        "#@markdown ##**Confirm your answers and then click \"Submit\"**\n",
        "import numpy as np\n",
        "import time\n",
        "from IPython.display import IFrame\n",
        "def prefill_form(src, fields: dict):\n",
        "  '''\n",
        "  src: the original src url to embed the form\n",
        "  fields: a dictionary of field:value pairs,\n",
        "  e.g. {\"pennkey\": my_pennkey, \"location\": my_location}\n",
        "  '''\n",
        "  prefills = \"&\".join([\"prefill_%s=%s\"%(key, fields[key]) for key in fields])\n",
        "  src = src + prefills\n",
        "  src = \"+\".join(src.split(\" \"))\n",
        "  return src\n",
        "\n",
        "#autofill time if it is not present\n",
        "try: t0;\n",
        "except NameError: t0 = time.time()\n",
        "try: t1;\n",
        "except NameError: t1 = time.time()\n",
        "try: t2;\n",
        "except NameError: t2 = time.time()\n",
        "try: t3;\n",
        "except NameError: t3 = time.time()\n",
        "\n",
        "#autofill fields if they are not present\n",
        "#a missing pennkey and pod will result in an Airtable warning\n",
        "#which is easily fixed user-side.\n",
        "try: my_pennkey;\n",
        "except NameError: my_pennkey = \"\"\n",
        "try: my_pod;\n",
        "except NameError: my_pod = \"Select\"\n",
        "try: general_thoughts;\n",
        "except NameError: general_thoughts = \"\"\n",
        "try: reflection_1;\n",
        "except NameError: reflection_1 = \"\"\n",
        "try: reflection_2;\n",
        "except NameError: reflection_2 = \"\"\n",
        "\n",
        "\n",
        "times = np.array([t1,t2,t3])-t0\n",
        "\n",
        "fields = {\"pennkey\": my_pennkey,\n",
        "          \"pod\": my_pod,\n",
        "          \"general_thoughts\":general_thoughts,\n",
        "          \"reflection_1\":reflection_1,\n",
        "          \"reflection_2\":reflection_2,\n",
        "          \"cumulative_times\": times}\n",
        "\n",
        "src = \"https://airtable.com/embed/shriUAJ2KuNJpXVkj?\"\n",
        "\n",
        "#now instead of the original source url, we do: src = prefill_form(src, fields)\n",
        "display(IFrame(src = prefill_form(src, fields), width = 800, height = 400))"
      ],
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "\n",
              "        <iframe\n",
              "            width=\"800\"\n",
              "            height=\"400\"\n",
              "            src=\"https://airtable.com/embed/shriUAJ2KuNJpXVkj?prefill_pennkey=value&prefill_pod=euclidean-wombat&prefill_general_thoughts=value&prefill_reflection_1=value&prefill_reflection_2=value&prefill_cumulative_times=[+4.35500288++7.7192421++10.18055534]\"\n",
              "            frameborder=\"0\"\n",
              "            allowfullscreen\n",
              "        ></iframe>\n",
              "        "
            ],
            "text/plain": [
              "<IPython.lib.display.IFrame at 0x7f6f50e5ab70>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "IdIisWVO2S6p"
      },
      "source": [
        "# Part 2. MuZero\n",
        "Read the muZero paper, the current state of the art : https://deepmind.com/research/publications/Mastering-Atari-Go-Chess-and-Shogi-by-Planning-with-a-Learned-Model. "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "O3IJ6UAE2gRJ"
      },
      "source": [
        "There is nothing to submit for this section, but try to contextualize this paper in terms of what we went over this week. Also familiarize yourself with the figures in the paper."
      ]
    }
  ]
}
